package cn.hibernatedemo.entity;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.HashSet;
import java.util.Set;

@Entity
public class Employee {
    private long empid;
    private String empname;
    private Set<Project> projects=new HashSet<Project>();

    public Set<Project> getProjects() {
        return projects;
    }

    public void setProjects(Set<Project> projects) {
        this.projects = projects;
    }

    public Employee(long empid, String empname) {
        this.empid = empid;
        this.empname = empname;
    }

    public Employee() {
    }



    @Id
    @Column(name = "EMPID")
    public long getEmpid() {
        return empid;
    }

    public void setEmpid(long empid) {
        this.empid = empid;
    }

    @Basic
    @Column(name = "EMPNAME")
    public String getEmpname() {
        return empname;
    }

    public void setEmpname(String empname) {
        this.empname = empname;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Employee employee = (Employee) o;

        if (empid != employee.empid) return false;
        if (empname != null ? !empname.equals(employee.empname) : employee.empname != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (empid ^ (empid >>> 32));
        result = 31 * result + (empname != null ? empname.hashCode() : 0);
        return result;
    }
}
